{template '', 'header'}
<script type="text/javascript">
$(function(){
	if($('#product_add').size() > 0) {	
		$('#product_add').fancybox({
				'width'				: 530,
				'height'			: 450,
				'href'				: '{APP_PATH}index.php?m=content&c=product&a=batchupload',
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
			});
	}
})
//修改产品标题
function changeTitle(obj, id, title)
{
	$('#td_'+id).html('<form action="" method="GET" onsubmit="return changeTitleSubmit('+id+', \''+title+'\');"><input type="text" name="title" id="title_'+id+'" value="'+title+'" /> <input type="submit" value="确认" /> <input type="button" value="取消" onclick="changeTitleCancel('+id+', \''+title+'\');" /></form>');
	$('#note_'+id).focus();
}
function changeTitleCancel(id,title)
{
	$('#td_'+id).html(title+' <a href="javascript:void(0);" onclick="return changeTitle(this, '+id+', \''+title+'\');" style="color:#999;">[修改]</a>');
}
function changeTitleSubmit(id, title) {
	var new_title = $('#title_'+id).val();
	if(new_title.length < 1 || new_title.length>16) {
		alert("产品标题长度请在1-16个字符之间！");
		$('#td_'+id).find('input:text').focus();
		return false;
	}
	if(title==new_title) {
		changeTitleCancel(id, title);
	} else {
		$('#td_'+id).find('input:button').attr('disabled', true);
		$('#td_'+id).find('input:submit').attr('disabled', true);
		$.getJSON('{APP_PATH}index.php?m=content&c=product&a=update_title', {ajax:1, id:id, title:new_title}, function(data){
			$('#td_'+data.id).html(data.new_title+' <a href="javascript:void(0);" onclick="return changeTitle(this, '+data.id+', \''+data.new_title+'\');"  style="color:#999;">[修改]</a>');
		});
	}
	return false;
}
</script>
<div id="main">
	<div class="user">
		{template '', 'account_manage_left'}
		<div class="right">
			<div class="po">当前位置：会员中心 > <span>我的产品</span></div>
			<div class="product">
				<p><input type="button" value="批量上传产品" {if $memberinfo[doupload]==0}onclick="alert('抱歉，您没有上传权限，请联系管理员开通！'); return false;"{else}id="product_add"{/if}> 当前分类共有{$content_total}条产品信息，本月被加入清单{$monthordernum}次，累积{$ordernum}次。</p>
				<ul class="subMenu">
					{php $i=1}
					<li><span><a href="{APP_PATH}index.php?m=content&c=product&a=init" {if $_GET[bid]==''}class="current"{/if}>全部</a></span>
						{if $_GET[bid]==''}<ul><li>您可以选择分类进行浏览！</li></ul>{/if}
					</li>					
					{loop $brands $r}
						<li><span><a href="{APP_PATH}index.php?m=content&c=product&a=init&bid={$r[id]}" {if $_GET[bid]==$r[id] || $brand[parentid]==$r[id]}class="current"{/if}>{$r[name]}</a></span>
						{php $i++}
						{pc:content action="category" catid="$r[catid]" num="25" siteid="1" order="listorder ASC"}
						{if $top_brand[child]}
						<ul>
						{loop $top_brand[child] $v}
							<li><a href="{APP_PATH}index.php?m=content&c=product&a=init&bid={$v[id]}" {if $_GET[bid]==$v[id]}class="current"{/if}>{$v[name]}</a></li>
						{/loop}
						</ul>
						{elseif $_GET[bid]!=''}
						<ul><li>此品牌下暂无分类！</li></ul>
						{/if}
						</li>						
					{/loop}
				</ul>	
				<table cellpadding="0" cellspacing="1">
					<thead>
						<tr>
							<td width="15%" align="center">缩略图</td>
							<td width="28%">产品名称</td>
							<td>最新求助信息</td>
							<td width="15%">加入清单次数</td>
							<td width="8%">操作</td>
						</tr>
					</thead>
					<tbody>
						{loop $product_data $v}
						<tr>
							<td align="center"><a href="{$v[thumb]}#{$v[id]}" rel="photoGroup" title="{$v[title]}"><img src="{thumb($v[thumb], 80, 55)}" width="80" height="55"/></a></td>
							<td id="td_{$v[id]}">{$v[title]} <a href="javascript:void(0);" onclick="return changeTitle(this, {$v[id]}, '{$v[title]}');" style="color:#999;">[修改]</a></td>
							<td>{if $v[myhelp][id]}[{date('m-d', $v[myhelp][inputtime])}] <a href="{APP_PATH}index.php?m=myhelp&productid={$v[id]}&id={$v[myhelp][id]}" title="{$v[myhelp][title]}" target="_blank">{str_cut($v[myhelp][title], 36)}</a>{/if}</td>
							<td align="center">{$v[ordernum]}</td>
							<td align="center"><a href="{APP_PATH}index.php?m=content&c=product&a=delete&id={$v[id]}" onclick="return confirm('确认要删除吗？');">删除</a></td>
						</tr>
						{/loop}
					</tbody>
					<tfoot>
						<tr>
							<td colspan="5">
								<div class="pageList">								
									{$product_pages}								
								</div>	
							</td>
						</tr>
					</tfoot>
				</table>
			</div>
		</div>
		<div class="clearit"></div>
	</div>
</div>
{template '', 'footer'}